import { useRequest } from "ahooks";

import {getAssetInfo} from '@/api/asset'

import {useSearchParams} from 'react-router-dom'

const useLoadAssetInfoData = () => {
  const [searchParams] = useSearchParams()

 const {error,loading,data,run,refresh} = useRequest(async ()=>{
    const search = searchParams.get('search') || ""
    const page = parseInt(searchParams.get('page') || "1")
    const pageSize = parseInt(searchParams.get('size') || "10")
    const res = await getAssetInfo({pageIndex:page,pageSize,search})
    return res
},{
    // refreshDeps:[searchParams],
    manual:true,
})

return  {error,loading,data,refresh,run}
}

export default useLoadAssetInfoData